package vpfarm.data;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;

public class Status implements Serializable{

	FrameInfo[] frames = null;
	JobInfo currentJob = null;
	JobInfo[] remainingJobs = null;
	byte[] latestImageByteData = null;
	
	
	public Status(FrameInfo[] f, JobInfo ji, ArrayList<JobInfo> jiList, String latestImage) throws IOException{
		System.out.println("\n\n\nErstelle neuen Status\n\n\n");
		if (f != null){
			this.frames = new FrameInfo[f.length];
			for (int i = 0; i < f.length; i++)
				this.frames[i] = f[i].copy();
		}
		if (ji != null)
			this.currentJob = ji.copy();
		if (jiList != null){
			this.remainingJobs = new JobInfo[jiList.size()];
			for (int i = 0; i < this.remainingJobs.length; i++)
				this.remainingJobs[i] = jiList.get(i).copy();
		}
		if (latestImage != null){
			File file = new File(latestImage);
			if (file.exists()){
				FileInputStream f_in = new FileInputStream(file);
				this.latestImageByteData = new byte[(int) file.length()];
				f_in.read(this.latestImageByteData);
			}
		}
	}


	public JobInfo getCurrentJob() {
		return currentJob;
	}


	public void setCurrentJob(JobInfo currentJob) {
		this.currentJob = currentJob;
	}


	public FrameInfo[] getFrames() {
		return frames;
	}


	public void setFrames(FrameInfo[] frames) {
		this.frames = frames;
	}


	public byte[] getLatestImageByteData() {
		return latestImageByteData;
	}


	public void setLatestImageByteData(byte[] latestImageByteData) {
		this.latestImageByteData = latestImageByteData;
	}


	public JobInfo[] getRemainingJobs() {
		return remainingJobs;
	}


	public void setRemainingJobs(JobInfo[] remainingJobs) {
		this.remainingJobs = remainingJobs;
	}
}
